package org.example8.iterator;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author Stranger
 * @version 1.0
 * @description: TODO
 * @date 2022/12/12 21:40
 */
public class ListContainer<T> implements Container<T> {

    private ArrayList<T> arrayList;

    public ListContainer(ArrayList<T> arrayList) {
        this.arrayList = arrayList;
    }

    @Override
    public Iterator<T> getIterator() {
        return new ListIterator<>();
    }

    private class ListIterator<T> implements Iterator<T> {

        private int index = 0;

        private Collection<T> collection;

        @Override
        public Boolean hasNext() {
            return index < arrayList.size();
        }

        @Override
        public T next() {
            return (T) arrayList.get(index++);
        }
    }

}
